<!DOCTYPE html>

<html>
    <head>
        <meta charset="utf-8">
        <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
        <!-- <p>搜索字符串“runoob”，并显示匹配的起始位置：</p> -->
        <p>替换“microsoft"为”Runnoob“：</p>
        <button onclick="myFunction()">点我</button>
        <!-- <p id="demo"></p> -->
        <p id="demo">Vsiit Microsoft!</p>
        <script>
            function myFunction() {
                // var str = "Visit Runoob!"
                // var n = str.search(/Runoob/i)
                // document.getElementById("demo").innerHTML = n
                var str = document.getElementById("demo").innerHTML
                var txt = str.replace(/microsoft/i, "Runoob")
                document.getElementById("demo").innerHTML = txt
            }
        </script>
    </body>
</html>